package com.szy.system.data.jpa.entity;

import org.springframework.data.domain.Persistable;

import javax.persistence.MappedSuperclass;
import javax.persistence.PostLoad;
import javax.persistence.PrePersist;
import javax.persistence.Transient;

/**
 * @author : zhenyun.su
 * @comment : 主键不推荐使用
 * @since : 2020/1/10
 */
@Deprecated
@MappedSuperclass
public abstract class AbstractID<ID> implements Persistable<ID> {
    @Transient
    private boolean isNew = true;
    @Override
    public boolean isNew() {
        return isNew;
    }
    @PrePersist
    @PostLoad
    void markNotNew() {
        this.isNew = false;
    }
}
